/**
 * 简易store用来处理依赖menuMsg的组件
 * 小红点数据可以通过此store来获取
 */
import { dispatch, model } from 'tva';

import { saveModel } from 'modules/tvaPlugin';

model({
    namespace: 'globalMenuStore',
    plugin: [saveModel()],
    state: {},
    reducer: {
        update(draft, { data }) {
            Object.assign(draft, data);
        },
    },
});

export function updateMenuMsgStore(patch = {}) {
    dispatch({
        type: 'globalMenuStore/update',
        data: patch,
    });
}
